<template>
  <PageWrapper title="关键词捕获" contentBackground content=" 根据关键词类别捕获样本训练的数据，识别同类问题的关键信息。如：我要九点半从新疆去云南" contentClass="p-4">
    <a-form
      :model="formState"
      name="basic"
      :label-col="{ span: 6 }"
      :wrapper-col="{ span: 14 }"
      autocomplete="off"
      @finish="onFinish"
      @finishFailed="onFinishFailed"
    >
      <a-form-item
        label="问题"
        name="sentence"
        :rules="[{ required: true, message: '请输入你的问题!' }]"
      >
        <a-input v-model:value="formState.sentence" />
      </a-form-item>
      <a-form-item :wrapper-col="{ offset: 6, span: 14 }">
        <a-button type="primary" html-type="submit">识别</a-button>
      </a-form-item>
      <a-form-item :wrapper-col="{ offset: 6, span: 14 }">
        <span>{{formState.answer}}</span>
      </a-form-item>
    </a-form>
  </PageWrapper>
</template>

<script lang="ts">
import {BasicForm, useForm} from '/@/components/Form/index';
import {computed, defineComponent, reactive} from 'vue';
import {defHttp} from '/@/utils/http/axios';
import { propTypes } from '/@/utils/propTypes';
import PageWrapper from "@/components/Page/src/PageWrapper.vue";
import {identification} from "@/views/ai/easyai/keywordcapture/KeywordCapture.api";
interface FormState {
  sentence: string;
  answer: string;
}
export default defineComponent({
  name: "AiKeywordCaptureForm",
  components:{
    PageWrapper
  },
  props:{

  },
  setup() {
    const formState = reactive<FormState>({
      sentence: '',
      answer: '',
    });
    const onFinish = (values: any) => {
      console.log('Success:', values);
      identification(values.sentence).then((res) => {
        formState.answer = res.result;
      });
    };

    const onFinishFailed = (errorInfo: any) => {
      console.log('Failed:', errorInfo);
    };
    return {
      formState,
      onFinish,
      onFinishFailed,
    };
  },
});
</script>
